s=input('Введите последовательность: ')
obr = '()[]{}<>'
s0 = []
s1 = []
s2 = []
s3 = []
s4 = []
s5 = []
s6 = []
s7 = []
s8 = []
for i in s:
   if i in obr:
      s0.append(i)
for i in s0:
    if i == '(':
        s1.append(i)
    if i == ')':
        s2.append(i)
    if i == '[':
        s3.append(i)
    if i == ']':
        s4.append(i)
    if i == '{':
        s5.append(i)
    if i == '}':
        s6.append(i)
    if i == '<':
        s7.append(i)
    if i == '>':
        s8.append(i)
if (len(s1)!=0 and len(s2)!=0 and len(s1)!=len(s2) ) or ( len(s3)!=0 and len(s4)!=0 and len(s3)!=len(s4) ) or (len(s5)!=0 and len(s6)!=0 and len(s5)!=len(s6)) or (len(s7)!=0 and len(s8)!=0 and len(s7)!=len(s8)):
    print("false")
else:
    print("true")
